<?xml version="1.0"?>
<xs:schema xmlns="http://www.defensoria.cl/Memo" elementFormDefault="qualified" targetNamespace="http://www.defensoria.cl/Memo" xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd"/>

	<xs:element name="Documento" type="DocumentoBaseType" />
  <xs:simpleType name="EmailTypeBase">
    <xs:restriction base="xs:string">
      <xs:pattern value=".*@.*\..*" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="RutTypeBase">
    <xs:restriction base="xs:string">
      <xs:minLength value="3" />
      <xs:maxLength value="10" />
      <xs:pattern value="[0-9]+-([0-9]|K)" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="FolioType">
    <xs:sequence>
      <xs:element name="Id" type="xs:positiveInteger" />
      <xs:element name="NoFolio" type="xs:positiveInteger" />
      <xs:element name="Anno">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:pattern value="([0-9]{4})" />
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="ContenidoType">
    <xs:sequence>
      <xs:element name="Folio" type="FolioType" />
      <xs:element name="Memo" type="MemoType" />
    </xs:sequence>
    <xs:attribute name="ID" type="xs:string" use="required" />
    <xs:attribute name="codigo" type="xs:string" use="required" />
  </xs:complexType>
  <xs:complexType name="DocumentoBaseType">
    <xs:sequence>
      <xs:element name="Contenido" type="ContenidoType" />
      <xs:element minOccurs="0" maxOccurs="unbounded" xmlns:q1="http://www.w3.org/2000/09/xmldsig#" ref="q1:Signature" />
    </xs:sequence>
    <xs:attribute name="urlDoc" type="xs:anyURI" use="required" />
    <xs:attribute fixed="1.0" name="version" type="xs:decimal" use="required" />
  </xs:complexType>
  <xs:complexType name="MemoType">
    <xs:sequence>
      <xs:element name="DAF" type="xs:string" />
      <xs:element name="Antecedente" type="xs:string" />
      <xs:element name="Materia" type="xs:string" />
      <xs:element name="De" type="xs:string" />
      <xs:element name="Para" type="xs:string" />
      <xs:element name="Glosa" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
</xs:schema>